package com.mall.common.utils;

import org.checkerframework.checker.units.qual.K;
import org.springframework.beans.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

public class BeanUtilKit extends BeanUtils {

    public  static <S,T> List<T> copyObjectList(List<S> sourceList , Class<T> clazz){
        List<T> targetList = new ArrayList<>();
        for (S source : sourceList) {
            T target = null;
            try {
                target = clazz.newInstance();
            } catch (Exception  e ) {
                throw new RuntimeException(e);
            }
           copyProperties(source, target);
            targetList.add(target);
        }
        return targetList;
    }


}
